#include "view_calories.h"
#include "prj_config.h"
#include "app_trace.h"
#include "battery_ctrl.h"
#include "blecom.h"
#include "common/common.h"
#include "datetime.h"
#include "display_ctrl.h"
#include "display_interface.h"
#include "font/font.h"
#include "font_mngr.h"
#include "heart_rate_interface.h"
#include "lfs_file_manager_auto.h"
#include "math.h"
#include "platform_assert.h"
#include "rtc.h"
#include "sport_his.h"
#include "view_calories.h"
#include "view_calories.inc"
#include "weather_ctrl.h"
#include "arabic_reshaper.h"
#include "utf8_to_unicode.h"
#define P_CALORIE_UNIT_X_POS 30
#define P_CALORIE_UNIT_Y_POS 141

void view_calories_base_display(void)
{
    if (disp_ctrl.loop_cnt == 0)
    {
        disp_ctrl.auto_refresh_time = 500;
        disp_ctrl.com_data.i_temp[0] = sport_get_calorie();
    }
    int num = disp_ctrl.com_data.i_temp[0];
    draw_on_chip_gradients_image(6, 8, zip_image_circle, 0xfa8a, 0xf8a2);
    draw_on_chip_gray_gif_array_filter_color(6, 8, zip_gif_calorie, sizeof(zip_gif_calorie) / sizeof(zip_gif_calorie[0]), 0xFFFF);
    draw_on_chip_gray_image(P_CALORIE_UNIT_X_POS, P_CALORIE_UNIT_Y_POS, zip_image_kcal, 0xfb6a);
    // gui_fbuf_draw_user_gray_image(P_CALORIE_UNIT_X_POS, P_CALORIE_UNIT_Y_POS, 0xfb6a, zip_image_kcal);
    draw_on_chip_image_num_center(num, 0, 108, OLED_SIZE_X - 1, 18 + 32 - 1, zip_curve_num_10x28, 10, 1, draw_type_normal);
}
void view_device_info_display(void)
{
    draw_device_info();
}
void view_calories_display(int view)
{
    switch (view)
    {
    case view_calories:
        view_calories_base_display();
        break;
    default:
        view_device_info_display();
        break;
    }
}
view_event_result_t view_device_info_event(event_param_t const *param)
{
    switch (param->event)
    {
    case event_button_front_press:
        return view_event_result_handled;
    case event_button_front_long_press:
        display_show(view_calories, DISP_MODE_DOWN_MOVE);
        return view_event_result_handled;
    }
    return view_event_result_not_handled;
}
view_event_result_t view_calories_event(int view, event_param_t const *param)
{
    if (view == view_calories)
    {
        return view_event_result_not_handled;
    }
    else
    {
        return view_device_info_event(param);
    }
}
